package pl.cvplus.entity;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_password", schema = "public", catalog = "")
@Entity
public class CpPassword {
    private String userPassword;

    @javax.persistence.Column(name = "user_password", nullable = false, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    private String salt;

    @javax.persistence.Column(name = "salt", nullable = false, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    private Integer userFk;

    @javax.persistence.Column(name = "user_fk", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getUserFk() {
        return userFk;
    }

    public void setUserFk(Integer userFk) {
        this.userFk = userFk;
    }

    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpPassword that = (CpPassword) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (salt != null ? !salt.equals(that.salt) : that.salt != null) return false;
        if (userFk != null ? !userFk.equals(that.userFk) : that.userFk != null) return false;
        if (userPassword != null ? !userPassword.equals(that.userPassword) : that.userPassword != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = userPassword != null ? userPassword.hashCode() : 0;
        result = 31 * result + (salt != null ? salt.hashCode() : 0);
        result = 31 * result + (userFk != null ? userFk.hashCode() : 0);
        result = 31 * result + (id != null ? id.hashCode() : 0);
        return result;
    }

    private CpUser cpUserByUserFk;

    @ManyToOne
    public
    @javax.persistence.JoinColumn(name = "user_fk", referencedColumnName = "id", nullable = false)
    CpUser getCpUserByUserFk() {
        return cpUserByUserFk;
    }

    public void setCpUserByUserFk(CpUser cpUserByUserFk) {
        this.cpUserByUserFk = cpUserByUserFk;
    }

    private Collection<CpUser> cpUsersById;

    @OneToMany(mappedBy = "cpPasswordByPasswordFk")
    public Collection<CpUser> getCpUsersById() {
        return cpUsersById;
    }

    public void setCpUsersById(Collection<CpUser> cpUsersById) {
        this.cpUsersById = cpUsersById;
    }
}
